﻿Ext.define('App.views.AppSelectorWindow', {
    extend: 'Ext.Window',
    requires: ['App.views.AppSelectorGrid'],
    title: 'Select Application',
    height: 300,
    width: 400,
    border: false,
    layout: 'fit',
    data: [],
    buttons: [
        {
            text: 'Select',
            handler: function (c) {
                c.ownerCt.ownerCt.selectApp();
            }
        }
    ],

    initComponent: function () {

        this.items = [
            {
                xtype: 'AppSelectorGrid',
                itemId: 'selectorGrid',
                listeners: {
                    scope: this,
                    itemdblclick: this.selectApp
                },
                data: this.data
            }
        ];

        this.callParent();
    },

    selectApp: function () {

        if (this.getComponent('selectorGrid').selectApp()) { // The application was selected
            this.close();
        }
    }
});